package com.test.chatrobot3.test;

import org.datavec.api.records.reader.RecordReader;
import org.datavec.api.records.reader.impl.csv.CSVRecordReader;
import org.datavec.api.split.FileSplit;
import org.datavec.api.writable.Writable;
import org.nd4j.common.io.ClassPathResource;

import java.io.File;
import java.util.List;

public class TextDataLoader {
    public static void main(String[] args) throws Exception {
        // 初始化 CSV 记录读取器
        int numLinesToSkip = 1; // 跳过 CSV 文件的标题行
        char delimiter = ',';   // CSV 文件的分隔符
        RecordReader recordReader = new CSVRecordReader(numLinesToSkip, delimiter);

        // 加载 CSV 文件
        File file = new ClassPathResource("data/dialogues.csv").getFile();
        recordReader.initialize(new FileSplit(file));

        // 读取数据
        while (recordReader.hasNext()) {
            List<Writable> record = recordReader.next();
            System.out.println(record);
        }

    }
}